package com.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.dao.IRetPrdGrdInfoDao;
import com.dao.IRetPrdJgeDao;
import com.model.Ret_prd_grd_info;
import com.model.Ret_prd_info;
import com.tx.Xpdefect.prdOXInfo;

@Repository
public class RetPrdGrdInfoHibernateDao extends GenericHibernateDao<Ret_prd_grd_info, String>
		implements IRetPrdGrdInfoDao {
	
	@Autowired
	private IRetPrdJgeDao retPrdJgeDao;
	
	public Ret_prd_grd_info resetOXInfo(Ret_prd_info ret_prd_info,boolean hxFlg){
		prdOXInfo prd_OX_info = new prdOXInfo();
		Ret_prd_grd_info prd_grd_info = new Ret_prd_grd_info();
		prd_grd_info = this.get(ret_prd_info.getPrd_seq_id());
		if(prd_grd_info == null){//找不到产品的OX信息
			return null;
		}
		
		prd_OX_info = retPrdJgeDao.getOXInfo(ret_prd_info,hxFlg);
		
		prd_grd_info.setPrd_qty(prd_OX_info.getPrd_qty());
		prd_grd_info.setPrd_seq_grd(prd_OX_info.getPrd_seq_grd());
		prd_grd_info.setPrd_seq_grd_t(prd_OX_info.getPrd_seq_grd_t());
		prd_grd_info.setPrd_seq_grd_c(prd_OX_info.getPrd_seq_grd_c());
		prd_grd_info.setCus_ng_qty(prd_OX_info.getCus_ng_qty());
		prd_grd_info.setProc_ng_qty(prd_OX_info.getProc_ng_qty());
		prd_grd_info.setAct_cus_ng_qty(prd_OX_info.getAct_cus_ng_qty());
		prd_grd_info.setAct_proc_ng_qty(prd_OX_info.getAct_proc_ng_qty());

		return prd_grd_info;
	}
}